#ifndef _UDPCLIENT_H_
#define _UDPCLIENT_H_

#define BUFFSIZE 1500

#include "PesPacket.h"
#include "TsPacket.h"
#include "RtpPacket.h"
#include "UdpDatagram.h"

#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <pthread.h>
#include <sys/time.h>
#include <gtk/gtk.h>


void _die(char *mess);


/// class UdpClient - 
class UdpClient {
  // Attributes
private:
    int sock;
    unsigned int echolen, clientlen, serverlen;
    int received;
    pthread_t thread1;

public:
  int port;
  struct sockaddr_in sockaddr_server;
  struct sockaddr_in sockaddr_client; //i'm the client and this is my address
  char buffer[BUFFSIZE];
  bool keepRunning;
  struct timeval  l_time;
  long int received_byte;
  long int received_packet;
  // Operations
public:
  UdpClient();
  void setPort(int _port);
  /// Stay listening forever
  bool startListening ();
  void startListeningThread (void *ptr );
  virtual bool process (UdpDatagram * udp_d) = 0;
  bool stopListening ();
};



#endif
